package com.thh.common.exception.sql;

import com.thh.common.exception.ServiceException;
import com.thh.common.exception.base.BaseException;

import java.sql.SQLException;

/**
 * @ClassName
 * @Desc
 * @Author tanhh
 * @Date 2022/6/29 11:15
 * @Version 1.0
 **/
public class SqlException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    /**
     * 错误提示
     */
    private String message;

    /**
     * 错误明细，内部调试错误
     */
    private String detailMessage;

    /*
     * 数据库id
     **/
    private Long databaseId;

    public Long getDatabaseId() {
        return databaseId;
    }

    /**
     * 空构造方法，避免反序列化问题
     */
    public SqlException()
    {
    }

    public SqlException(Exception e)
    {
        this.message = e.getMessage();
    }


    public SqlException(Long databaseId, String message)
    {
        this.databaseId = databaseId;
        this.message = message;
    }

    public SqlException(String message)
    {
        this.message = message;
    }

    public String getDetailMessage()
    {
        return detailMessage;
    }

    public SqlException setDetailMessage(String detailMessage)
    {
        this.detailMessage = detailMessage;
        return this;
    }

    public String getMessage()
    {
        return message;
    }

    public SqlException setMessage(String message)
    {
        this.message = message;
        return this;
    }
}
